package com.athay.diary.entity;

public enum Role {
    USER(1, "普通用户"),
    ADMIN(2, "管理员");

    private final Integer value;
    private final String description;

    Role(Integer value, String description) {
        this.value = value;
        this.description = description;
    }

    public Integer getValue() {
        return value;
    }

    public String getDescription() {
        return description;
    }

    public static Role fromValue(Integer value) {
        for (Role role : Role.values()) {
            if (role.value.equals(value)) {
                return role;
            }
        }
        throw new IllegalArgumentException("Invalid role value: " + value);
    }
}